package com.t216.hot216.controller;

import com.github.pagehelper.PageInfo;
import com.t216.hot216.pojo.HotEvents;
import com.t216.hot216.service.HotEventsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/hot")
public class HotEventsController {
    @Resource
    private HotEventsService hotEventsService;

    @GetMapping("/list")
    public Map<String,Object> hotEvents(String keyWord,@RequestParam(defaultValue = "1") int pageNo) {
        PageInfo<HotEvents> pageInfo = hotEventsService.getHotsByPage(keyWord,pageNo);
        Map<String,Object> map = new HashMap<>();
        map.put("pageInfo",pageInfo);

        return map;
    }
}
